<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 
        1.promise和定时器的执行顺序
        2.await的作用
          2.1得到promise的结果
          2.2 阻塞了线程
     -->
    <script>
        async function show(){
            console.log("script-start");
            var res = await go()
            console.log(res);
        }
        async function go(){
            return 1
        }
        show()
        setTimeout(()=>{
            console.log(4);
        },1000)
        var p = new Promise((resolve,reject)=>{
            console.log(2);
            resolve(3)
        })
        p.then((res)=>{
            console.log(res);
        })
        console.log("script-start");
        /* 
        script-start
        2
        script-start
        1
        3
        4
        */
    </script>
</body>
</html>